#include<bits/stdc++.h>
using namespace std;
map<string,int> mp;
struct hh{
	int num,k;
	set<string> s;
};
int main(){
	int n,max_=-1;
	string yao,max_s;
	cin>>n;
	vector<hh> bingli(n);
	for(int i=0;i<n;i++){
		cin>>bingli[i].num>>bingli[i].k;
		for(int j=0;j<bingli[i].k;j++){
			cin>>yao;
			mp[yao]++;
			bingli[i].s.insert(yao);
		}
	}
	for(auto it=mp.begin();it!=mp.end();it++){
		if(it->second>max_) {
			max_=it->second;
			max_s=it->first;
		}
	}
	cout<<max_s<<" "<<max_<<endl; 
	for(int i=0;i<n;i++){
		if(bingli[i].s.find(max_s)!=bingli[i].s.end())
			printf("%04d\n",bingli[i].num);
	}
}
